<style>
    body {
        background-color: #ffffff;
    }

    .layui-upload-choose {
        max-width: 200px;
        padding: 0 10px;
        color: #999;
        font-size: 14px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
    }
</style>

<div class="layui-form layuimini-form">


    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>文件上传</legend>
    </fieldset>

    <div class="layui-btn-container">
        <button type="button" class="layui-btn" id="upload-button">选择文件</button>
        <button class="layui-btn layui-btn-normal" type="button" id="saveBtn">确认上传</button>
    </div>

</div>
<script>
    layui.use(['form', 'upload'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;
        var upload = layui.upload;
        upload.render({
            elem: '#upload-button'
            , accept: 'file'
            , auto: false
            ,url: '{:url("upload/add")}'
            , exts: "{:get_allow_upload_ext('|')}"
            , bindAction: '#saveBtn'
            , done: function (res) {
                if (res.code == 0) {
                    var index = layer.msg("上传成功", {icon: 1}, function () {
                        layer.close(index);
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                        parent.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
                return false;
            }
        });

    });
</script>